<?php
declare(strict_types=1);
namespace Field;

class SysAlbumConst
{
    public const pk='AlbumID';
    public const index=['AlbumID'];
	public const fields=['AlbumID','ParentAlbumID','Name','CreateAt','UpdateAt'];
	public const comment=['AlbumID'=>'素材目录ID','ParentAlbumID'=>'素材目录ID','Name'=>'相册,名称','CreateAt'=>'创建时间','UpdateAt'=>'更新时间'];
	/*
    * @Field AlbumID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 素材目录ID
    */
    public const AlbumID = 'AlbumID';
    /*
    * @Field ParentAlbumID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 素材目录ID
    */
    public const ParentAlbumID = 'ParentAlbumID';
    /*
    * @Field Name
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 相册,名称
    */
    public const Name = 'Name';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 创建时间
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 更新时间
    */
    public const UpdateAt = 'UpdateAt';
}

class SysAlbumColumns
{
public  int $AlbumID;
   public  int $ParentAlbumID;
   public  ?string $Name='';
   public  ?string $CreateAt='';
   public  ?string $UpdateAt='';
	public function toArray():array
	{
		return [
'AlbumID'=>$this->AlbumID,
    'ParentAlbumID'=>$this->ParentAlbumID,
    'Name'=>$this->Name,
    'CreateAt'=>$this->CreateAt,
    'UpdateAt'=>$this->UpdateAt,        ];
	}
}

class SysAlbumRow
{
	public SysAlbumColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'AlbumID' => $this->data->AlbumID,
        'ParentAlbumID' => $this->data->ParentAlbumID,
        'Name' => $this->data->Name,
        'CreateAt' => $this->data->CreateAt,
        'UpdateAt' => $this->data->UpdateAt, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new SysAlbumColumns();
        isset($data['AlbumID']) && $this->data->AlbumID = (int)$data['AlbumID'];
           isset($data['ParentAlbumID']) && $this->data->ParentAlbumID = (int)$data['ParentAlbumID'];
           isset($data['Name']) && $this->data->Name = (string)$data['Name'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
    }
}
?>